<?php

declare(strict_types=1);

namespace App\Robot\Amqp\Consumer;

use App\CustHub\Constants\ContactTaskCenterStatusConstants;
use App\CustHub\Constants\ContactTaskCenterTyperConstants;
use App\CustHub\Model\ChContact;
use App\CustHub\Model\ChContactTaskCenter;
use App\CustHub\Service\ChCrowSendingService;
use App\CustHub\Service\ChSendRecordService;
use App\Robot\Job\DelayedTaskJob;
use App\Robot\Job\SendRecordJob;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use Hyperf\Amqp\Result;
use Hyperf\AsyncQueue\Driver\DriverFactory;
use PhpAmqpLib\Message\AMQPMessage;
use function Hyperf\Collection\data_get;
use function Hyperf\Coroutine\co;

#[Consumer(exchange:"crow_sending", routingKey:"crow_sending", queue:"crow_sending", name:"CrowSending", nums:1)]
class CrowSendingConsumer extends ConsumerMessage
{
    public function consumeMessage($data, AMQPMessage $message): Result
    {
        logger()->info('群发队列'.json_encode($data));
        container()->get(ChCrowSendingService::class)->sendRobotQueue($data['data']);
        return Result::ACK;
    }


    public function isEnable(): bool
    {
        return \Hyperf\Support\env('AMQP_CONSUMER_ENABLE',false);
    }
}